package com.dailyblue.java.standard.network.socket.udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Clients {
    public static void main(String[] args) throws Exception{
        // 创建客户端套接字，指定端口号
        DatagramSocket socket = new DatagramSocket(8877);
        byte[] data = new byte[1024];
        // 创建了一个接收📦
        DatagramPacket packet = new DatagramPacket(data, data.length);
        // 接收发送过来的数据
        while (true){
            socket.receive(packet);
            String message = new String(data);
            System.out.println(message);
            Thread.sleep(4000);
        }
    }
}
